<template>
  <el-dialog
    title="添加敏感词"
    :visible.sync="visible"
    :close-on-click-modal="false"
    top="8vh"
  >
    <el-form :model="form" ref="form">
      <el-form-item label="" prop="">
        <el-input v-model="form.content"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="">
      <el-button type="primary" @click="onSubmit">保存</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  components: {},
  data() {
    return {
      visible: false,
      form: {
        content: "",
      },
    };
  },
  methods: {
    open() {
      this.visible = true;
      this.form.content = "";
    },
    onSubmit() {
      this.$refs.form.validate((form) => {
        this.axios
          .post(`/user/addSensetive`, { words: [this.form.content] })
          .then((res) => {
            if (res.retCode != 0) {
              return this.$message.error(res.retMsg);
            }
            this.$emit("added");
            this.$message.success("操作成功!");
            this.visible = false;
          });
      });
    },
  },
};
</script>

<style scoped>
::v-deep .el-date-editor.el-input,
::v-deep .el-date-editor.el-input__inner {
  width: 100%;
}
</style>